var { ReturnModel } = require('../libs/resmodel');
var { accessrecordList } = require('../services/accessrecord');

/**
* 获取访客记录列表
* @api {post} /accessrecord/list 获取访客记录列表
* @apiDescription 获取用户申请查看列表
* @apiName list
* @apiParam (参数) {String} pcode 关联员工code
* @apiParam (参数) {Number} pagenum 查询第几页(默认第1页)
* @apiParam (参数) {Number} pagesize 每页显示条数(默认10条)
* @apiSampleRequest /accessrecord/list
* @apiGroup accessrecord-访客记录
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598",
*       "pagenum": 1,  // 查询第几页
*       "pagesize": 10,  // 每页显示条数
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": 
*        list: [{
*       "pcode": "290464549598", // 被访问用户code
*       "accesscode": "249485919615", // 访客code
*       "code": "249485919615", // 访客code
*       "accessinfo": {nickname:'xx', avator:'xxx',age:29, grender:'男',birthday:'1999/10/23',star:'天蝎座',height:175,signature:'个性签名',education:'硕士'}, // 访客信息
*       "createtime": "2022-04-02 15:23:22", // 访问时间
*       }],
*        "total": 200,//总条数
*        "pagecount": 20,//总页数
*        }
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function list(req, res) {
    let result = await accessrecordList(req.body);
    res.json(new ReturnModel(result));
}

module.exports = function (app) {
    let base_url = '/api/accessrecord';

    app.post(base_url+'/list', list);
}
